package io.renren.modules.PCguanli.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.PCguanli.dao.LineDao;
import io.renren.modules.PCguanli.entity.LineEntity;
import io.renren.modules.PCguanli.service.LineService;


@Service("lineService")
public class LineServiceImpl extends ServiceImpl<LineDao, LineEntity> implements LineService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String id_card = (String) params.get("idcard");
        String deptId = (String) params.get("deptId");
        String[] deptIdArr = deptId.split(",");

        IPage<LineEntity> page = this.page(
                new Query<LineEntity>().getPage(params),
                new QueryWrapper<LineEntity>()
                        .like(StringUtils.isNotBlank(id_card), "idcard",id_card)
                        .in(StringUtils.isNotEmpty(deptId), "dept_id",deptIdArr)
                        .orderByAsc("lineorder") // 添加这行来按照lineorder字段进行升序排序
        );
        return new PageUtils(page);
    }

}